package cn.nnxy.zentao.controller;

import cn.nnxy.zentao.domain.List1User;
import cn.nnxy.zentao.service.List1;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("back/user")
public class ListController {
    @Autowired
    private List1 list1;

    @GetMapping("userList")
    public String queryAllUser(Integer curPage,Integer pageSize, Model model) {//查询所有。。。日程
        Zong(curPage,null,pageSize,model);
        return "我的地盘-我的待办 - 禅道"; }
    @GetMapping("userList1")
    public String queryAllUser1(Integer curPage,String str,Integer pageSize, Model model) {//条件查询。。。最高
        Zong(curPage,str,pageSize,model);
        return "我的地盘-我的待办 - 禅道"; }
    @PostMapping("userList2")
    public String queryAllUser2(Integer curPage,String str,Integer pageSize, Model model) {//条件查询。。。倒叙Zong(curPage,str,pageSize,model);
        Zong(curPage,str,pageSize,model);
        return "我的地盘-我的待办 - 禅道";
    }

    private void Zong(Integer curPage,String str,Integer pageSize, Model model){
        curPage = null == curPage ? 1 : curPage;//当前页数
        pageSize = null == pageSize ? 20 : pageSize;//一页显示条数
        PageHelper.startPage(curPage, pageSize);
        List<List1User> users = list1.queryAlls(str);
        PageInfo<List1User> pageInfo = new PageInfo<List1User>(users);
        model.addAttribute("users", users);
        model.addAttribute("pageInfo", pageInfo);
    }

}
